package com.baidu.controller;

import com.baidu.entity.Borr;
import com.baidu.service.LoansService;
import com.baidu.utils.ResultResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description:  放款模块控制层
 * @Author: 李亚丹
 * @Date: 2021/12/14
 */
@RestController
@Slf4j
@RequestMapping("loan")
public class LoansController {
    @Resource
    private LoansService loansServes;

    /**
     * 预还款记录
     * @param borr 产品pid，期数的nid,和借款金额prices
     * @return ResultResponse
     */
    @RequestMapping("preview")
    public ResultResponse preview(@RequestBody Borr borr){
        return loansServes.preview(borr);
    }

    /**
     * 用户点击借款
     * @param borr 用户id，是否同意协议产品pid，期数nid，借款金额prices
     * @return ResultResponse
     */
    @RequestMapping("borrow")
    public ResultResponse borrow(@RequestBody Borr borr){
        return loansServes.borrow(borr);
    }

    /**
     * 查询各种列表通过map形式返回
     * @return ResultResponse
     */
    @RequestMapping("particulars")
    public ResultResponse particulars(){
        return loansServes.particulars();
    }

    /**
     * 查询审已审核通过的产品列表
     * @return ResultResponse
     */
    @RequestMapping("product")
    public ResultResponse product(){
        return loansServes.product();
    }

    /**
     * 所有收益的展示接口
     * @return ResultResponse
     */
    @RequestMapping("proa")
    public ResultResponse proa(){
        return loansServes.proa();
    }

    /**
     * 查看用户自己还未还款的记录
     * @param borr 用户id
     * @return  ResultResponse
     */
    @RequestMapping("over")
    public ResultResponse over(@RequestBody Borr borr){
        return loansServes.over(borr);
    }

    /**
     * 用户查看自己借款产品对应的预还款记录
     * @param borr userid是否登录，主键id
     * @return ResultResponse
     */
    @RequestMapping("onesr")
    public ResultResponse onesr(@RequestBody Borr borr){
        return loansServes.onesr(borr);
    }

}
